package demo1;

public class demo_07isInterrupt {
    static boolean isQuit=false;
    public static void main(String[] args) throws InterruptedException {
        Thread thread =new Thread(()->{
            while (!isQuit) {
                System.out.println("线程正在运行。。。。。");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });
        //启动线程
        thread.start();
        //让thread线程运行一会
        Thread.sleep(3000);
        //修改标志位，让他停止
        isQuit=true;
    }
}
